package chapter04;

import java.text.NumberFormat;
import java.util.Locale;
import java.util.Scanner;

/**
 * 把数字转换为货币字符串
 * 通过使用numberFormat类格式化成货币格式
 * Created by a on 2017/6/9.
 */
public class Test060 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数字:");
        double number = scanner.nextDouble();
        System.out.println("该数字可以获得不同得货币格式:");
        //创建格式化对象
        NumberFormat format  = NumberFormat.getCurrencyInstance(Locale.CHINA);
        //输出格式化货币格式
        System.out.println(format.format(number));
        format = NumberFormat.getCurrencyInstance(Locale.US);
        System.out.println(format.format(number));
        format = NumberFormat.getCurrencyInstance(Locale.UK);
        System.out.println(format.format(number));
        format = NumberFormat.getCurrencyInstance(Locale.ENGLISH);
        System.out.println(format.format(number));
        format = NumberFormat.getCurrencyInstance(Locale.TAIWAN);
        System.out.println(format.format(number));
    }
}
